package cn.com.wanywhn.a2017_04_02_bmob_brvah;

import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;

import com.squareup.picasso.Picasso;

import de.hdodenhof.circleimageview.CircleImageView;

public class Info_edit extends AppCompatActivity {

    FloatingActionButton fab;
    CircleImageView mCircleImageView;
    Toolbar toolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_info_edit);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            //透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        //TODO 找到更好的方法，比如通过Behaviour
        fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                mCircleImageView.setVisibility(fab.getVisibility());
                return true;
            }
        });
        initview();
    }

    private void initview() {
        mCircleImageView = (CircleImageView) findViewById(R.id.info_header);
        Picasso.with(mCircleImageView.getContext()).load(getIntent().getStringExtra("url")).into(mCircleImageView);
    }


}
